<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Settings_Model extends CI_Model {
  public function getPlatformName() {
    return $this->db->get('settings')->row()->platform_name;
  }
  
  public function getTemplateFolder() {
    return $this->db->get('settings')->row()->template_folder;
  }
  
  public function getSettings() {
    return $this->db->get('settings')->row();
  }
  
  public function getRegisterTypes() {
    return array(
      0 => 'Registro aberto',
      1 => 'Validação por e-mail',
      2 => 'Validação do administrador',
      3 => 'Registro fechado'
    );
  }
  
  public function getTimezones() {
    $raw_timezones = $this->db->get('timezone')->result();
    $timezones = array();
    foreach ($raw_timezones as $timezone)
      $timezones[$timezone->id] = $timezone->description;
    return $timezones;
  }
  
  public function updateSettings($data) {
    $this->db->update('settings', $data);
  }
}
